package com.lpit.service.impl;

import com.lpit.constant.Constant;
import com.lpit.dto.ArticleHomeDto;
import com.lpit.result.ResponseResult;
import com.lpit.service.BloggerHomePageService;
import com.lpit.vo.HomePageDataVo;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author Yao Chen
 */
@RestController
public class BloggerHomePageServiceImpl implements BloggerHomePageService {
    /**
     *  查询首页的数据
     * @param articleHomeDto
     * @return ResponseResult<List<HomePageDataVo>>
     */
    @Override
    public ResponseResult<List<HomePageDataVo>> bloggerHomePage(ArticleHomeDto articleHomeDto){
        if(null == articleHomeDto){
            articleHomeDto = new ArticleHomeDto();
        }
        if(null == articleHomeDto.getChannelName() || "".equals(articleHomeDto.getChannelName())){
            articleHomeDto.setChannelName("推荐");
        }
        if(null ==articleHomeDto.getSize() || 0 == articleHomeDto.getSize() ){
            articleHomeDto.setSize(10);
        }
        if(null == articleHomeDto.getNewestTime() || "".equals(articleHomeDto.getNewestTime())){
            articleHomeDto.setNewestTime(new SimpleDateFormat(Constant.TIME_FORMAT).format(new Date()));
        }

        return null;
    }
}
